import Vue from 'vue'
import VueRout from 'vue-router'
import Home from '../pages/Home'
import List from "../pages/List"
import Music from '../pages/Home/Music'
import Play from '../pages/Home/Play'
import Work from '../pages/Home/Work'
Vue.use(VueRout)
// 每次都添加很麻烦,所以直接在VueRout中复写push函数
let oldPush = VueRout.prototype.push
VueRout.prototype.push = function (location, cb = () => { }, cb2 = () => { }) {
    // 函数获取时this为空,所以需要修改this指向
    oldPush.call(this, location, cb, cb2)
}
export default new VueRout({
    routes: [
        {
            path: "/home",
            component: Home,
            children: [
                {
                    path: 'music',
                    component: Music,
                },
                {
                    path: 'play',
                    name: 'play',
                    component: Play,
                },
                {
                    path: 'Work',
                    component: Work,
                },
            ]
        },
        {
            path: "/list",
            component: List
        }
    ]
})